import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:libflutter/view/LayoutLogPrint.dart';

class TestPageViewWidget extends StatefulWidget {
  const TestPageViewWidget({super.key});

  @override
  State<TestPageViewWidget> createState() {
    return _PageViewState();
  }
}

class _PageViewState extends State<TestPageViewWidget> {
  @override
  Widget build(BuildContext context) {
    var children = <Widget>[];
    // 生成 6 个 Tab 页
    for (int i = 0; i < 6; ++i) {
      children.add(Page(
        value: "index ${i}",
      ));
    }

    return Scaffold(
      appBar: AppBar(
        title: const Text("基础组件 PageView 学习"),
      ),
      body: PageView(
        children: children,
      ),
    );
  }
}

class Page extends StatefulWidget {
  final String value;

  const Page({super.key, required this.value});

  @override
  State<StatefulWidget> createState() {
    return _PageState();
  }
}

class _PageState extends State<Page> {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text(" Page >> ${widget.value}"),
    );
  }
}
